#ifndef _SYN_MIDI_H
#define _SYN_MIDI_H

#include "syncommon.h"

namespace Synth {

class Mixer;

enum Controllers {
	CC_MODULATION,
	CC_FILTERCUTOFF,
	CC_FILTERREZ,
	CC_PAN,
	CC_PITCHBEND,
	CC_MAX
};

enum MidiEventType {
	ME_KEYDOWN, 
	ME_KEYUP, 
	ME_MAX
};

enum {
	NUM_EVENTTYPES = ME_MAX + CC_MAX
};

struct MIDIEvent {
	unsigned int time;
	unsigned char type;
	unsigned char channel;
	unsigned char data1;
	unsigned char data2;
	bool operator < (const MIDIEvent &other) {
		if (time == other.time)
			return type < other.type;
		else
			return time < other.time;
	}
};

class MIDIPlayer {
	MIDIEvent *buffer;
	MIDIEvent *bufptr;
	int currentTime;
public:
	Mixer *mixer;
	MIDIPlayer();
	void LoadSong(const unsigned char *data);
	void TimeStep(unsigned int newTime);
};

}  // namespace

#endif